package Offer;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class p数组中数字出现的次数II {
    class Solution {
        public int singleNumber(int[] nums) {
            HashMap<Integer, Integer> map = new HashMap<>();
            for (int num : nums) {
                map.put(num, map.getOrDefault(num, 0) + 1);
            }
            Set<Map.Entry<Integer, Integer>> entries = map.entrySet();
            for (Map.Entry<Integer, Integer> entry : entries) {
                if (entry.getValue() == 1){
                    return entry.getKey();
                }
            }
            return -1;
        }
    }
}
